//
//  Tipe_WX_Image.m
//  ZITHER
//
//  Created by weixin on 2019/5/13.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "Tipe_WX_Image.h"

@implementation Tipe_WX_Image

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor greenColor];
        [self setCornerRadiusWithRadius:16 isMasks:YES];
        [self setUI];
        [self setMasonry];
    }
    return self;
}


-(void)setUI{
    [self addSubview:self.labTitle];
    [self addSubview:self.labTitleSub];
    [self addSubview:self.btn];
    
}

-(void)setMasonry{
    @weakify(self);
    [self.labTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        @strongify(self);
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self).offset(-15);
        make.top.equalTo(self).offset(20);
        make.height.mas_equalTo(15);
    }];
    
    [self.labTitleSub mas_makeConstraints:^(MASConstraintMaker *make) {
        @strongify(self);
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self).offset(-15);
        make.top.equalTo(self.labTitle.mas_bottom).offset(10);
    }];
    
    [self.btn mas_makeConstraints:^(MASConstraintMaker *make) {
        @strongify(self);
        make.left.equalTo(self).offset(15);
        make.bottom.equalTo(self.mas_bottom).offset(-30);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(32);
    }];
    
}


-(BaseLab *)labTitle{
    if (!_labTitle) {
        _labTitle = [BaseLab initCustomLab:@"手表识别功能" color:[UIColor whiteColor] font:[UIFont fontWithName:@"Arial-BoldMT" size:10]];
        _labTitle.numberOfLines = 1;
        _labTitle.backgroundColor = [UIColor clearColor];
    }
    return _labTitle;
}

-(BaseLab *)labTitleSub{
    if (!_labTitleSub) {
        _labTitleSub = [BaseLab initCustomLab:@"智能识别手表，获取手表详细参数，以及价格列表，最高历史价格，最近历史价格" color:[UIColor whiteColor] font:[UIFont fontWithName:@"Arial-BoldMT" size:12]];
        _labTitleSub.numberOfLines = 0;
        _labTitleSub.backgroundColor = [UIColor clearColor];
    
    }
    return _labTitleSub;
}

-(BaseBtn *)btn{
    if (!_btn) {
        _btn = [BaseBtn initCustomBtnTitlestype:@[@"更多"] color:@[Main_Token_Model_MANAGER.backgroundColor]];
        [_btn setCornerRadiusWithRadius:16 isMasks:YES];
    }
    return _btn;
}

-(void)setModel:(Tipe_Model_WX *)model{
    _model = model;
    self.image = [UIImage imageNamed:model.imgaeUrl];
    self.labTitle.text = model.Ttile;
    self.labTitleSub.text = model.TtileSub;
    [self.btn setTitle:model.BtnTitle forState:UIControlStateNormal];
}

@end
